package com.hao.study.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hao.study.entity.Classification;
import com.hao.study.mapper.ClassificationMapper;
import com.hao.study.service.ClassificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: author
 * @description:
 * @date: 2024/6/11 17:51
 * @version: 1.0
 */
@Service
public class ClassificationServiceImpl implements ClassificationService {
    @Autowired
    ClassificationMapper classificationMapper;
    @Override
    public void creatClassification(Classification classification) {
        System.out.println(classification);
        classification.setCreateTime(String.valueOf(System.currentTimeMillis()));
        classificationMapper.insert(classification);
    }

    @Override
    public PageInfo<Classification> getClassificationList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Classification> list=classificationMapper.selectList(new QueryWrapper<>());
        return PageInfo.of(list);
    }

    @Override
    public void deleteClassification(String id) {
        classificationMapper.deleteById(id);
    }

    @Override
    public void updateClassification(Classification classification) {
        classificationMapper.updateById(classification);
    }
}
